﻿using System;
using System.Windows;
using System.Windows.Data;

namespace DictationTool.Common
{
    public sealed class TimeSpanToString : IValueConverter
    {
        object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
                return string.Empty;

            TimeSpan timeSpan = (TimeSpan)value;
            if (timeSpan != null)
            {
                return (timeSpan.TotalHours > 1) ? timeSpan.ToString(@"hh\:mm\:ss") : timeSpan.ToString(@"mm\:ss");
            }
            return "00:00";
        }

        object IValueConverter.ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    //public sealed class TimeSpanToDouble : IMultiValueConverter
    //{
    //    public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    //    {
    //        if (values[0] == null)
    //            return 0;

    //        double seekValue =(double)values[0];
    //        double maxinum = (double)values[1];
    //        double mediaPlayerWidth = (double)values[2];

    //        return mediaPlayerWidth * (seekValue / maxinum) - 4;
    //    }

    //    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
    //    {
    //        throw new NotImplementedException();
    //    }
    //}

    public sealed class BoolToVisible : IValueConverter
    {
        object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return (value is bool) && (bool)value ? 1 : 0;
        }

        object IValueConverter.ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    //public sealed class ValueToWidth : IMultiValueConverter
    //{
    //    object IMultiValueConverter.Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    //    {
    //        double sliderValue = (double)values[0];
    //        double maxinum = (double)values[1];
    //        double mediaPlayerWidth = (double)values[2];

    //        return mediaPlayerWidth * (sliderValue / maxinum);
    //    }

    //    object[] IMultiValueConverter.ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
    //    {
    //        throw new NotImplementedException();
    //    }
    //}

    public sealed class ValueToFontSize : IValueConverter
    {
        object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return (int)(double)value;
        }

        object IValueConverter.ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    //public sealed class ObjectToVisible : IValueConverter
    //{
    //    object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    //    {
    //        return (value == null) ? Visibility.Visible : Visibility.Collapsed;
    //    }

    //    object IValueConverter.ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    //    {
    //        throw new NotImplementedException();
    //    }
    //}
}
